package com.hundredapp.oa.web.action;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import com.hundredapp.oa.repository.UserManager;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@Repository
@Scope("prototype")
public class Index extends ActionSupport {
	
	@Autowired
	private UserManager userManager;
	
	private String username;
	
	public String execute(){
		Map<String, Object> session_map=ActionContext.getContext().getSession();
		if(session_map.get("lgoin_user_id")!=null){
			username=userManager.findUserById(Integer.parseInt(session_map.get("lgoin_user_id").toString())).getDisplayName();
		}
		return SUCCESS;
	}

	public UserManager getUserManager() {
		return userManager;
	}
	
	public void setUserManager(UserManager userManager) {
		this.userManager = userManager;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}
}
